🖥️ ⚙️ 🧠
The Brain of the Computer
The Central Processing Unit (CPU) is the "brain" of a computer.
Its job is to execute instructions and process data.
The CPU is made up of several components that work together in a cycle: fetch → decode → execute → store.
Performs arithmetic operations: addition, subtraction, multiplication, division.
Performs logical operations: AND, OR, NOT, XOR, comparisons (>, <, =)
Works directly with data stored in registers.
👉 Example: If the instruction is C = A + B, the ALU adds the values of A and B and stores the result in C.
Acts like a manager/traffic controller of the CPU.
Fetches instructions from memory, decodes them, and sends signals to ALU, registers, and memory.
Controls data flow within the CPU and between CPU & other parts of the computer.
👉 Example: When a program says "Add A and B", the CU tells registers to load A and B, ALU to perform addition, and where to store the result.
Very small, very fast storage inside CPU.
Hold data, addresses, or instructions temporarily.
👉 Example: When executing C = A + B, values of A and B are loaded into registers before being sent to ALU.
Holds the address of the next instruction
Holds the current instruction
Stores intermediate results
Holds memory address and data
A small, high-speed memory located inside or near the CPU.
Stores frequently used instructions/data to avoid slow access from main RAM.
Levels: L1 (fastest, smallest), L2, L3 (slower, bigger).
👉 Example: If a loop is running many times, the instructions and data are stored in cache so CPU doesn't fetch them repeatedly from RAM.
Communication channels that carry information:
👉 Example: When A + B is executed, Address Bus points to memory locations of A and B, Data Bus carries their values to CPU, and Control Bus signals whether it's a read or write operation.
Generates timing signals to synchronize CPU operations.
Measured in Hertz (Hz) = cycles per second.
Faster clock = more instructions executed per second.
👉 Example: A CPU with 3 GHz clock can run ~3 billion cycles per second.
Let's say we want the CPU to execute:
Instruction: C = A + B
CU uses PC to fetch the instruction ADD A, B → C from memory into IR. PC increments to point to next instruction.
CU decodes instruction: operation = ADD, operands = A & B.
CU signals ALU: perform A + B. Registers hold A and B temporarily. ALU computes result.
Result stored in register or memory location C.
CU fetches next instruction using updated PC.
Performs calculations and logic operations
Manages and coordinates operations
Fast temporary storage
High-speed memory buffer